import Node  from "../Node";
export default class TextTure extends Node{
    image=""
    povit={x:0.5,y:0.5}
    
    constructor(prop){
        super(prop)
        this.image = prop.image
    }
    render(context) {

        // console.log(this.image)
        // debugger
        // context.drawImage(this.image,0,0,this.image.width,this.image.height,
        //     -this.image.width/this.povit ,0,this.image.width*this.dm.worldScale.scale,this.image.height*this.dm.worldScale.scale)
      

        context.drawImage(this.image,0,0,this.image.width*this.dm.worldScale.scale,this.image.height*this.dm.worldScale.scale)

    }
    getTexureData(pos){
      let imgClip = this.dm.canvasLayers.find(layer=>layer.name==='img-clip')
      imgClip.canvas.style=`width:${pos.w}px;height:${pos.h}px;`;           
      imgClip.canvas.width=pos.w;
      imgClip.canvas.height=pos.h;

      imgClip.render.render(this.image,pos);
      
     
      return  imgClip.canvas.toDataURL()
      
       
    }
    toObj(){
        let obj = super.toObj()
        return {
          ...obj,
          image:this.image,
          povit:this.povit
        }
      }
}